package com.gitee.feizns.zxw.web.controller.backstage;

import com.gitee.feizns.web.domain.result.Ret;
import com.gitee.feizns.web.domain.page.PageAo;
import com.gitee.feizns.web.domain.page.PageVoRet;
import com.gitee.feizns.web.mvc.validate.annotation.Exists;
import com.gitee.feizns.zxw.domain.pojo.GourmetAccommodationHotelEvaluationTagsMap;
import com.gitee.feizns.zxw.domain.backstage.ao.gourmet.accommodation.hotel.evaluation.tags.map.ListAo;
import com.gitee.feizns.zxw.domain.backstage.ao.gourmet.accommodation.hotel.evaluation.tags.map.CreateAo;
import com.gitee.feizns.zxw.domain.backstage.ao.gourmet.accommodation.hotel.evaluation.tags.map.UpdateAo;
import com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.hotel.evaluation.tags.map.ListVo;
import com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.hotel.evaluation.tags.map.DetailsVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gitee.feizns.zxw.service.backstage.GourmetAccommodationHotelEvaluationTagsMapService;

/**
 * @author feizns
 * @since 2019/09/09
 */
@Validated
@RestController
@RequestMapping("/api/v1/backstage/gourmet/accommodation/hotel/evaluation/tags/map")
public class GourmetAccommodationHotelEvaluationTagsMapController {

    @Autowired
    private GourmetAccommodationHotelEvaluationTagsMapService gourmetAccommodationHotelEvaluationTagsMapService;

    /**
     * 列表
     * @param page
     * @param ao
     * @return com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.home.evaluation.tags.statistics.FirstVo
     */
    @GetMapping
    public Ret<PageVoRet<ListVo>> list(PageAo page, ListAo ao) {
        return Ret.ok(gourmetAccommodationHotelEvaluationTagsMapService.list(page, ao));
    }

    /**
     * 详情
     * @param id
     * @return com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.home.evaluation.tags.statistics.FirstVo
     */
    @GetMapping("/{id}")
    public Ret<DetailsVo> details(@PathVariable @Exists(GourmetAccommodationHotelEvaluationTagsMap.class) Integer id) {
        return Ret.ok(gourmetAccommodationHotelEvaluationTagsMapService.details(id));
    }

    /**
     * 添加
     * @param ao
     * @return com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.home.evaluation.tags.statistics.FirstVo
     */
    @PostMapping
    public Ret<DetailsVo> create(@Validated @RequestBody CreateAo ao) {
        return Ret.ok(gourmetAccommodationHotelEvaluationTagsMapService.create(ao));
    }

    /**
     * 修改
     * @param id
     * @param ao
     * @return com.gitee.feizns.zxw.domain.backstage.vo.gourmet.accommodation.home.evaluation.tags.statistics.FirstVo
     */
    @PutMapping("/{id}")
    public Ret<DetailsVo> update(@PathVariable @Exists(GourmetAccommodationHotelEvaluationTagsMap.class) Integer id, @Validated @RequestBody UpdateAo ao) {
        return Ret.ok(gourmetAccommodationHotelEvaluationTagsMapService.update(id, ao));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Ret<Void> delete(@PathVariable @Exists(GourmetAccommodationHotelEvaluationTagsMap.class) Integer id) {
        return Ret.ok(() -> gourmetAccommodationHotelEvaluationTagsMapService.delete(id));
    }

}
